package cn.com.zpark.jsp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @PackageName: cn.com.zpark.jsp
 * @ClassName: ServletDemp01
 * @Description:
 * @author: RZS
 * @date: 2021/11/28  8:28
 */
@WebServlet("/s1.do")
public class ServletDemp01 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        /**
         * 将数据绑定到request、session、context
         *
         */
        request.setAttribute("name","request");
        request.getSession().setAttribute("name","session");
        getServletContext().setAttribute("name", "context");

        // 转发
        request.getRequestDispatcher("/jsp/jsp03.jsp").forward(request, response);
    }
}
